
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:myapp/home/home_controller.dart';

import 'index/tab_index.dart';
import 'list/tab_list.dart';
import 'person/tab_person.dart';

class HomePage extends StatelessWidget {

  final HomeController navController = Get.put(HomeController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Obx(() => IndexedStack(
        index: navController.tabIndex.value,
        children: [
          TabIndex(),
          TabList(),
          TabPerson()
        ],
      )),
      bottomNavigationBar: Obx(() => BottomNavigationBar(
        currentIndex: navController.tabIndex.value,
        type: BottomNavigationBarType.fixed,
        selectedFontSize: 12,
        unselectedFontSize: 12,
        onTap: (index) => navController.changeTabIndex(index),
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
          BottomNavigationBarItem(icon: Icon(Icons.list), label: "列表"),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
        ],
      )),
    );
  }
}